home *** CD-ROM | disk | FTP | other *** search
/ Languguage OS 2 / Languguage OS II Version 10-94 (Knowledge Media)(1994).ISO / gnu / dejagnu.lha / dejagnu-1.0.1 / dejagnu / example / calc / testsuite / calc.test / calc.exp
Text File  |  1993-05-05  |  1KB  |  61 lines

  1. set timeout 3
  2. #
  3. # expectations that clean up in case of error. Note that `$test' is
  4. # a purely local variable.
  5. #
  6. # The first of these is used to match any bad responses, and resynchronise
  7. # things by finding a prompt. The second is a timeout error, and shouldn't
  8. # ever be triggered.
  9. #
  10. expect_after {
  11.     -re "\[^\n\r\]*$prompt$" {
  12.         fail "$test (bad match)"
  13.         if { $verbose > 0 } {
  14.             regexp ".*\r\n(\[^\r\n\]+)(\[\r\n\])+$prompt$" \
  15.                         $expect_out(buffer) "" output
  16.             send_user "\tUnmatched output: \"$output\"\n"
  17.         }
  18.     }
  19.     timeout {
  20.         fail "$test (timeout)"
  21.     }
  22. }
  23. #
  24. # Here are the tests
  25. #
  26. set test "version"
  27. send "version\n"
  28. expect {
  29.     -re "Version:.*$prompt$"    { pass "version" }
  30. }
  31.  
  32. set test add1
  33. send "add 3 4\n"
  34. expect {
  35.     -re "7+.*$prompt$"        { pass "$test" }
  36. }
  37.  
  38. set test add2
  39. send "add 1 2 3\n"
  40. expect {
  41.     -re "Usage: add #1 #2.*$prompt$" { pass "$test" }
  42. }
  43.  
  44. set test multiply1
  45. send "multiply 3 4\n"
  46. expect {
  47.     -re "12.*$prompt$"        { pass "$test" }
  48. }
  49.  
  50. set test multiply2
  51. send "multiply 2 4\n"
  52. expect {
  53.     -re "8.*$prompt$"        { pass "$test" }
  54. }
  55.  
  56. set test multiply3
  57. send "multiply 1 2 3\n"
  58. expect {
  59.     -re "Usage: multiply #1 #2.*$prompt$" { pass "$test" }
  60. }
  61.